<template>
  <div class="login-container">
    <div class="login-form">
      <h2>元气陪玩后台管理系统（程序员端）</h2>
      <form @submit.prevent="handleLogin">
        <div class="form-group">
          <label for="username">账号</label>
          <input
            type="text"
            id="username"
            v-model="username"
            placeholder="请输入账号"
            required
          />
        </div>
        <div class="form-group">
          <label for="password">密码</label>
          <input
            type="password"
            id="password"
            v-model="password"
            placeholder="请输入密码"
            required
          />
        </div>
        <button type="submit" class="login-btn">登录</button>
      </form>
      <div class="tips">
        <p>忘记密码？</p>
        <p>联系管理员获取帮助</p>
      </div>
    </div>
  </div>
</template>

<script>
import tenantApi from '@/http/tenantApi';

export default {
  name: "VitalityLogin",
  data() {
    return {
      username: "",
      password: "",
    };
  },
  methods: {
    handleLogin() {
      tenantApi.login({
        account: this.username,
        password: this.password,
      }).then((res) => {
        if (res.code === 200) {
          // 登录成功
          this.$message.success("登录成功");
          // 跳转到首页
          this.$router.push("/tenant");
        } else {
          // 登录失败
          this.$message.error(res.message);
        }
      });
      
    },
  },
};
</script>

<style scoped>
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-color: #f5f7fa;
  font-family: Arial, sans-serif;
}

.login-form {
  background: white;
  padding: 40px;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  width: 320px;
  text-align: center;
}

.login-form h2 {
  color: #333;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: #666;
  font-size: 14px;
}

.form-group input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-sizing: border-box;
}

.login-btn {
  width: 100%;
  padding: 12px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
}

.login-btn:hover {
  background-color: #0056b3;
}

.tips {
  margin-top: 20px;
  font-size: 12px;
  color: #999;
}
</style>
